﻿using System;
using System.Windows.Forms;
using KTD_XSMS.Properties;
using KTDSMS;

namespace KTD_XSMS
{
    public partial class RegisterProduct : Form
    {
        public string key = null;
        public RegisterProduct()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Dispose();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtSerialKey.Text == "")
            {
                Unity.Message("Please insert serial key.");
                txtSerialKey.Focus();
                return;
            }
            StringHash hash = new StringHash();
            if (hash.Encrypt(txtCodeProduct.Text.Trim()) == txtSerialKey.Text.Trim())
            {
                Unity.Message("Register Successfull");
                Settings.Default.PK = txtSerialKey.Text.Trim();
                Settings.Default.CheckKey = "Yes";
                Settings.Default.Save();
                base.Dispose();
            }
            else
            {
                Unity.Message("Serial key do not exactly");
                txtSerialKey.Focus();
                return;
            }

        }

        private void RegisterProduct_Load(object sender, EventArgs e)
        {
            txtCodeProduct.Text = key;
        }
    }
}
